package leetcode.code0069;

public class Solution extends Solution69 {

	@Override
	public int mySqrt(int x) {
		int ans = 0;
		int l = 0;
		int r = x;
		while (l <= r) {
			int m = ((r - l) >> 1) + l;
			if ((long)m * m > x) {
				r = m - 1;
			} else {
				ans = m;
				l = m + 1;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
//		so.debug1();
//		so.debug2();
//		so.debug3();
		so.debug4();
//		so.debug5();
	}

}
